﻿<div class="layui-card">
    <div class="layui-card-body">
        <table id="edition-table" lay-filter="edition-table"></table>
    </div>
</div>

<script type="text/html" id="edition-toolbar">
    <button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
        <i class="layui-icon layui-icon-add-1"></i>新增
    </button>
</script>

@section scripts{
    <script type="text/javascript">
        layui.use(['table'], function () {
            var $ = layui.$;
            var table = layui.table;

		    table.render({
		        elem: '#edition-table',
		        url: "@Url.Action("GetOrderList", "Order")",
                page: false,
                height: 'full-60',
                parseData: function (res) {
                    return {
                        "code": res.code,
                        "msg": res.msg,
                        "count": res.count,
                        "data": res.data
                    };
                },
                response: {
                    statusCode: 200
                },
		        cols: [
		            [
		                { title: '名称', field: 'displayName' }
		            ]
		        ],
		        skin: 'line',
		        toolbar: '#edition-toolbar',
		        defaultToolbar: [{
		            layEvent: 'refresh',
		            icon: 'layui-icon-refresh',
		        }, 'filter', 'print', 'exports']
		    });

		    table.on('toolbar(edition-table)', function(obj){
		        if(obj.event === 'add'){
		            window.add();
		        }
            });

            window.add = function () {
				parent.layer.open({
                    type: 2,
                    title: "添加订单",
                    content: "@Url.Action("CreateOrUpdate", "Order")",
                    area: ["600px","320px"],
                    shade: 0.1,
                    btn: ['确定', '取消'],
                    yes: function (index, layero) {
                        parent.window['layui-layer-iframe'+ index].submitForm();
                    }
                });
            }
        });
    </script>
}